package com.linq.cool.api.factory;

import com.linq.cool.api.domain.SysLoginLog;
import com.linq.cool.api.domain.SysOperateLog;
import com.linq.cool.api.feign.RemoteSysLogService;
import com.linq.cool.common.core.domain.Result;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author: yqlin
 * @Date: 2020/12/29 17:09
 * @Description: 日志服务降级处理
 * @Version: 1.0.0
 */
@Component
@Slf4j
public class RemoteSysLogFallbackFactory implements FallbackFactory<RemoteSysLogService> {
    @Override
    public RemoteSysLogService create(Throwable throwable) {
        log.error("日志服务调用失败: {}", throwable.getMessage());
        return new RemoteSysLogService() {
            @Override
            public Result<?> saveOperateLog(SysOperateLog operateLog) {
                return null;
            }

            @Override
            public Result<?> saveLoginLog(SysLoginLog loginLog) {
                return null;
            }

        };
    }
}
